package br.com.mmm.javacenter.framework.view.taglib.helper;

import java.io.IOException;


import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.tagext.JspFragment;

import br.com.mmm.autocenter.fornecedores.entity.Cpf;
import br.com.mmm.javacenter.framework.annotations.RenderComponent;
import br.com.mmm.javacenter.framework.reflection.ReflectionFacade;

@RenderComponent({
	Cpf.class
})
public class InputCPF extends Input{

	public InputCPF() {
	
	}
	public InputCPF(JspContext context, JspFragment fragment) {
		super(context, fragment);
	}
	
	public void addAttributesDefault() throws IOException {
		writer.write(getAtributo("name",name + "_numero"));
		writer.write(getAtributo("id",id + "_numero"));
		writer.write(getAtributo("value", rf.get("numero")));
		writer.write(getAtributo("maxLength",9));
		writer.write(getAtributo("size",9));
	}
	
	public void afterInput() throws IOException {
		writer.write("&nbsp;");
		writer.write("<input ");
		writer.write(getAtributo("name", getName() + "_digito"));
		writer.write(getAtributo("id",getId() + "_numero"));
		writer.write(getAtributo("value", rf.get("digito")));
		writer.write(getAtributo("size", 2));
		writer.write(getAtributo("maxLength", 2));
		writer.write("/>");
		writer.write("<input ");
		writer.write(getAtributo("type", "hidden"));
		writer.write(getAtributo("name",getName()));
		writer.write(getAtributo("id",getName()));
		writer.write("/>");
	}
}
